package com.em.sugarfight.controller;

import com.em.sugarfight.entity.GameState;
import com.em.sugarfight.entity.MoveCommand;
import com.em.sugarfight.service.OperateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OperateController {

    private static final Logger logger = LoggerFactory.getLogger(OperateController.class);

    @Autowired
    OperateService operateService;


    @PostMapping("/api/v1/command")
    public MoveCommand getOperateCommand(@RequestBody GameState allParam){
        logger.info("输入游戏数据为{}",allParam);
        MoveCommand moveCommand = operateService.analysAndOperate(allParam);
        logger.info("输出指令{}",moveCommand);
        return moveCommand;
    }

    @RequestMapping(value = "/api/v1/ping",method = RequestMethod.HEAD)
    public MoveCommand head(){
        return new MoveCommand("U",true,50);
    }

}
